package logic

import (
	"context"

	"HD_running/mall/order/api/internal/svc"
	"HD_running/mall/order/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type FindstuLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewFindstuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindstuLogic {
	return &FindstuLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *FindstuLogic) Findstu(req *types.FindstuReq) (resp *types.FindstuResp, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.StudentcourseModel.FindOne(l.ctx, req.Sno)
	if err != nil {
		return nil, err
	}
	return &types.FindstuResp{Sno: list.Cno, Cname: list.Cname, Sname: list.Sname}, nil
}
